package com.dlsp.hotel.controller.admin.home;

import com.dlsp.hotel.bean.RoomType;
import com.dlsp.hotel.service.AccountService;
import com.dlsp.hotel.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author:fanxh
 * @date: 2021/12/31/15:09
 */
@Controller
@RequestMapping("/home/index")
public class HomeController {
    @Autowired
    private AccountService accountService;
    @Autowired
    private RoomTypeService roomTypeService;

    /**
     * 前台首页
     * @param model
     * @param name
     * @return
     */
    @RequestMapping(value="/indexUi",method= RequestMethod.GET)
    public String indexUi(ModelAndView modelAndView, String name, Model model){
        Map<String,Object> queryMap = new HashMap<String, Object>();
        queryMap.put("name", name);
        queryMap.put("offset", 0);
        queryMap.put("pageSize", 999);
        List<RoomType> roomTypeList = roomTypeService.findAll();
        model.addAttribute("roomTypeList",roomTypeList);
        modelAndView.addObject("roomTypeList", roomTypeService.findList(queryMap));
        modelAndView.addObject("kw", name);
        return "pages/home/index/index";
    }

}
